﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;


namespace PloobsEngine.SceneControl
{
    public class ToBlackPostEffect : IPostEffect
    {

        Effect effect = null;        
        EngineStuff engine;
        RenderTarget2D tr2d;
        public Texture2D t;
        
        public void Draw(IRenderHelper rHelper,  Microsoft.Xna.Framework.GameTime gt, Microsoft.Xna.Framework.Rectangle screenRec, IWorld world)
        {
             //RenderTarget2D x = (RenderTarget2D)EngineStuff.GraphicsDevice.GetRenderTarget(0);
             //EngineStuff.GraphicsDevice.SetRenderTarget(0, tr2d);
             effect.Parameters["EXTRA"].SetValue(rHelper[PrincipalConstants.extra1RT]);
             effect.Parameters["color"].SetValue(rHelper[PrincipalConstants.CurrentImage]);             
             effect.Parameters["halfPixel"].SetValue(EngineStuff.HalfPixel);
             rHelper.RenderTextureToFullScreenVertexPixel(effect);
             //EngineStuff.GraphicsDevice.SetRenderTarget(0, x);
             //t = tr2d.GetTexture();
        }

        public void init(EngineStuff engine)
        {
            effect = EngineStuff.InternalContentManager.GetAsset<Effect>("ToBlack");            
            this.engine = engine;
            tr2d = new RenderTarget2D(EngineStuff.GraphicsDevice, EngineStuff.BackBufferWidth, EngineStuff.BackBufferHeight, 0, SurfaceFormat.Color,RenderTargetUsage.PreserveContents);

        }

    }
}


